package com.software.fanfan.exception;

import com.software.fanfan.constant.ResultEnum;

/**
 * 自定义系统业务异常：
 * 通过传入一个异常枚举类，统一管理异常的code和message
 *
 * Created by shiyanfei on 2018-01-09.
 */
public class BusinessException extends RuntimeException {

    private int code;

    public BusinessException(){
        super();
    }

    public BusinessException(ResultEnum resultEnum){
        super(resultEnum.getMessage());
        this.code = resultEnum.getCode();
    }

    public BusinessException(Throwable cause){
        super(cause);
    }

    public BusinessException(ResultEnum resultEnum,Throwable cause){
        super(resultEnum.getMessage(),cause);
        this.code = resultEnum.getCode();
    }

    public int getCode(){
        return code;
    }
}
